﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;

namespace YJKFamilyComparison
{
	internal struct DocumentXlsStruct
	{
		internal DocumentXlsStruct(string Name)
		{
			this.count = 0;
			this.docName = Name;
			this.docXlsStruct = new Dictionary<string, Dictionary<string, List<KeyValuePair<string, Color>>>>();
		}

		internal void Init(TreeNode tnInput)
		{
			if (tnInput.Nodes.Count > 0)
			{
				foreach (object obj in tnInput.Nodes)
				{
					TreeNode treeNode = (TreeNode)obj;
					if (treeNode.Nodes.Count == 0)
					{
						string name = (treeNode.Parent.Parent.Tag as ResultPackerBase).Name;
						string name2 = (treeNode.Parent.Tag as ResultPackerBase).Name;
						string text = treeNode.Text;
						System.Drawing.Color foreColor = treeNode.ForeColor;
						this.Add(name, name2, text, foreColor);
					}
					this.Init(treeNode);
				}
			}
		}

		internal void Add(string categoryName, string familyName, string elementName, System.Drawing.Color color)
		{
			if (this.docXlsStruct.Keys.Contains(categoryName))
			{
				if (!this.docXlsStruct[categoryName].Keys.Contains(familyName))
				{
					this.docXlsStruct[categoryName].Add(familyName, new List<KeyValuePair<string, Color>>());
				}
			}
			else
			{
				Dictionary<string, List<KeyValuePair<string, Color>>> dictionary = new Dictionary<string, List<KeyValuePair<string, Color>>>();
				dictionary.Add(familyName, new List<KeyValuePair<string, Color>>());
				this.docXlsStruct.Add(categoryName, dictionary);
			}
			this.docXlsStruct[categoryName][familyName].Add(new KeyValuePair<string, Color>(elementName, color));
			this.count++;
		}

		public string DocName
		{
			get
			{
				return this.docName;
			}
		}

		public Dictionary<string, Dictionary<string, List<KeyValuePair<string, Color>>>> DocXlsStruct
		{
			get
			{
				return this.docXlsStruct;
			}
		}

		public int Count
		{
			get
			{
				return this.count;
			}
		}

		private string docName;

		private Dictionary<string, Dictionary<string, List<KeyValuePair<string, Color>>>> docXlsStruct;

		private int count;
	}
}
